<?php
defined('_JEXEC') or die('Restricted access');
include(JPATH_COMPONENT . '/helpers.php');
$app = JFactory::getApplication();
$input = $app->input;
$itemid = $input->get('Itemid');

$item  = $input->getArray();

$jsonData = json_decode($item['jsonData']);
$series = $jsonData->series;
$itemTitle = $series->name;
foreach ($series->data  as $value) {
    $typename[] = str_replace('lg','<',$value->name);
    $values[] = $value->value;
}

$listEvent = $this->get('Event');
$vName = $input->get('view');
$selectType =  $input->get('type');
$id = $input->get('id');
if ($id) {
    $charTitle = $listEvent[$id]->event_name;
}
?>
<div class="res-title-rg">
    <span class="fl pos-icon text-c"><i class="audience"></i></span>
    <div class="title-info">
        <h2 class="fontsize20">Counting Event</h2>
        <p><a href="#">Home</a>&nbsp;/&nbsp;Audience&nbsp;/&nbsp;Counting Event</p>
    </div>
</div>
<div class="ws-content pdall15">
<div class="camtab">
    <div class="dropdown fr">
        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
            Click to select an event
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
        <?php foreach ($listEvent as $key => $value): ?>
        	<li class="selected"><a href="/index.php?option=com_console&view=<?php echo $vName; ?>&task=<?php echo $vName; ?>&Itemid=<?php echo $itemid ?>&type=<?php echo $value->event_id ?>&id=<?php echo $value->id ?>"><?php echo $value->event_name?></a></li>
      	<?php endforeach ?>
        </ul>
    </div>
</div>
<?php if ($series->data): ?>
    <div id="main" style="height:520px;"></div>
<?php else: ?>
 	<p class="ws-tips">No report data found.</p>
<?php endif; ?>
</div>
<script type="text/javascript">
	createHistogram({
		divId: 'main',
		title: '<?php echo $charTitle?>',
		names: <?php echo json_encode($typename)?>,
		values: <?php echo json_encode($values)?>
	});

</script>
